import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { ProductMaterialRelVO, ProductMaterialRelForm, ProductMaterialRelQuery } from '@/api/product/productMaterialRel/types';

/**
 * 查询产品与物料关系列表
 * @param query
 * @returns {*}
 */

export const listProductMaterialRel = (query?: ProductMaterialRelQuery): AxiosPromise<ProductMaterialRelVO[]> => {
  return request({
    url: '/product/productMaterialRel/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询产品与物料关系详细
 * @param relId
 */
export const getProductMaterialRel = (relId: string | number): AxiosPromise<ProductMaterialRelVO> => {
  return request({
    url: '/product/productMaterialRel/' + relId,
    method: 'get'
  });
};

/**
 * 新增产品与物料关系
 * @param data
 */
export const addProductMaterialRel = (data: ProductMaterialRelForm) => {
  return request({
    url: '/product/productMaterialRel',
    method: 'post',
    data: data
  });
};

/**
 * 修改产品与物料关系
 * @param data
 */
export const updateProductMaterialRel = (data: ProductMaterialRelForm) => {
  return request({
    url: '/product/productMaterialRel',
    method: 'put',
    data: data
  });
};

/**
 * 删除产品与物料关系
 * @param relId
 */
export const delProductMaterialRel = (relId: string | number | Array<string | number>) => {
  return request({
    url: '/product/productMaterialRel/' + relId,
    method: 'delete'
  });
};
